package com.meilai.project.mapper.business.customer;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.meilai.project.controller.mini.vo.customer.MiniCustomerInfoVO;
import com.meilai.project.dto.business.customer.CustomerInfoDTO;
import com.meilai.project.entity.business.customer.CustomerInfo;
import com.meilai.project.vo.business.customer.*;
import com.meilai.project.vo.business.workbench.BaseWeekCustomerVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 客户信息表 Mapper 接口
 * </p>
 *
 * @author xhy
 * @since 2022-01-06
 */
@Mapper
public interface CustomerInfoMapper extends BaseMapper<CustomerInfo> {

    /**
     * 根据用户ID获取当前人跟进的客户
     *
     * @return
     */
    List<CustomerInfo> listAll(@Param("userId") Long userId);

    List<CustomerInfoVO> page(@Param("page") Page<CustomerInfoVO> page, @Param("name") String name, @Param("industry_id") Long industry_id, @Param("userIds") List<Long> userIds, @Param("type") Integer type, @Param("boss_ids") List<Long> boss_ids, @Param("maintenance_staff_id") Long maintenance_staff_id);

    List<CustomerInfoVO> allPage(@Param("page") Page<CustomerInfoVO> page, @Param("name") String name, @Param("industry_id") Long industry_id, @Param("follow_up") Boolean follow_up, @Param("deptId") Long deptId);

    List<CustomerInfo> pageForBF(@Param("page") Page<CustomerInfo> page, @Param("name") String name, @Param("userIds") List<Long> userIds);

    List<Long> pageIdsForBF(@Param("page") Page<CustomerInfo> page, @Param("name") String name, @Param("contractBeginDate") String contractBeginDate, @Param("contractEndDate") String contractEndDate, @Param("executionStatus") Integer executionStatus,@Param("userIds") List<Long> userIds);

    CustomerInfoDTO getOneDtoById(@Param("id") Long id);

    List<BaseWeekCustomerVO> queryCustomerInfoByDate(@Param("userId") Long userId, @Param("type") Integer type, @Param("begin_date") LocalDate begin_date, @Param("end_date") LocalDate end_date, @Param("boss_ids") List<Long> boss_ids);

    List<CustomerAdvanceVO> queryAdvanceList(@Param("user_id") Long user_id);

    List<CompanyCustomerAdvanceVO> queryCompanyAdvanceList(@Param("ids") List<Long> ids);

    /**
     * 查询客户池列表
     *
     * @param page
     * @param name
     * @param industry_id
     * @param boss_ids
     * @return
     */
    List<BaseCustomerPoolVO> selectPage(@Param("page") Page<BaseCustomerPoolVO> page,
                                        @Param("name") String name,
                                        @Param("industry_id") Long industry_id,
                                        @Param("boss_ids") List<Long> boss_ids,
                                        @Param("type") Integer type);

    List<PublicSeaVO> selectPublicSeaPage(@Param("page") Page<PublicSeaVO> page,
                                          @Param("name") String name,
                                          @Param("industry_id") Long industry_id,
                                          @Param("boss_ids") List<Long> boss_ids,
                                          @Param("type") Integer type);

    List<CustomerInfoScheduledJobVO> queryList();

    MiniCustomerInfoVO queryDetail(@Param("id") Long id);

    List<CompanyCustomerAdvanceVO> queryCustomerInfoPage(@Param("page") Page<CompanyCustomerAdvanceVO> page,
                                                         @Param("type") Integer type,
                                                         @Param("boss_ids") List<Long> boss_ids,
                                                         @Param("name") String name,
                                                         @Param("user_id") Long user_id);

    List<CompanyCustomerAdvanceVO> queryCustomerInfoPageOrderByFollowDesc(@Param("page") Page<CompanyCustomerAdvanceVO> page,
                                                         @Param("type") Integer type,
                                                         @Param("boss_ids") List<Long> boss_ids,
                                                         @Param("name") String name,
                                                         @Param("user_id") Long user_id);

    List<CustomerInfo> queryAllByType(@Param("type") Integer type, @Param("user_id") Long user_id, @Param("boss_ids") List<Long> boss_ids);
}
